<template>

  <div>
    <el-row
      type="flex"
      justify="center"
      class="rowH"
      style="height:40px; margin-top:20px"
    >
      <el-col :span="6">
        <el-switch
          style="display: block;font-size:20px"
          v-model="value2"
          active-color="#13ce66"
          inactive-color="#409eff"
          @change="changeRouter(flag)"
          active-text="操作日志"
          inactive-text="登录日志"
        >
        </el-switch>
      </el-col>
    </el-row>
    <el-row>
      <transition :name="transitionName">
      <router-view></router-view>
      </transition>
    </el-row>
  </div>

</template>

<script>
export default {
  data () {
    return {
      value2: true,
      flag: 1,
      transitionName: ''
    }
  },
  mounted () {
  },
  methods: {
    changeRouter (flag) {
      if (flag === 1) {
        this.$router.push('/loginlog')
        this.flag = 2
      }
      if (flag === 2) {
        this.$router.push('/operationlog')
        this.flag = 1
      }
    }
  },
  components: {},
  watch: {
    $route (to, from) {
      if (to.meta.index > from.meta.index) {
        this.transitionName = 'slide-left'
      } else {
        this.transitionName = 'slide-right'
      }
    }
  }
}
</script>

<style scoped>
@import "../../assets/css/reset.css";
@import "../../assets/css/client.css";
.slide-right-enter-active,
.slide-right-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
  /* // 启用硬件加速 */
  will-change: transform;
  transition: all 200ms;
  position: fixed;
}
.slide-right-enter {
  transform: translate(-100%, 0);
  transition-timing-function: ease-in;
}
.slide-left-enter {
  transform: translate(100%, 0);
}
</style>
